package bdcin.servlet.actions.tese;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bdcin.excecoes.RemoverException;
import bdcin.fachada.BDCInFactory;
import bdcin.fachada.IBDCIn;
import bdcin.servlet.actions.Action;

public class RemoverTeseAction extends Action {

	@Override
	public void executar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		IBDCIn facade = BDCInFactory.getFacade();
		
		String id = request.getParameter("id");
		Long idl = Long.valueOf(id);
		
		try {
			facade.removerDocumento(idl);
		} catch (RemoverException e) {
			request.setAttribute("mensagem", e.getMessage());
			request.getRequestDispatcher("mensagem.jsp").forward(request, response);
		}
		
		
	}

}
